Ext.define('ArvoreKD.ux.data.proxy.Ajax', {
    extend: 'ArvoreKD.ux.data.proxy.Server',
    alias: 'proxy.uxajax',
    
    doRequest: function(operation, callback, scope) {
		this.doRequestDwr(operation, callback, scope);
    },
	
	/**
	 * Metodo criado para realizar buscas usando DWR.
	 */
	doRequestDwr: function(operation, callback, scope) {
		var me = this,
			request = me.buildRequest(operation),
			facade = Ext.decode(request.url);
		
		facade({
			callback: me.createRequestCallback(request, operation, callback, scope),
			errorHandler: me.createRequestErrorHandler()
		});
	},
	
	createRequestCallback: function(request, operation, callback, scope) {
        var me = this;
        
        return function(response) {
            me.processResponse(operation, request, response, callback, scope);
        };
    },
	
	createRequestErrorHandler: function() {
		return function(mensagem, erro) {
			alert('Falha na funcao createRequestErrorHandler: ' + mensagem);
		};
	}
});
